package com.tituaem.utilityclass;

import com.tituaem.operacionesBd.Consultas;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

public class Class_Login extends Consultas{
    private String usuario=null;
    private String password=null;
    private boolean aceptar;
    private Connection con;
    private boolean admin;
    
    public Class_Login()throws ClassNotFoundException, SQLException{
        this.con=super.getCon();
    }
    
    public void log(String us, String pass) throws SQLException{
        if(us.isEmpty()&&pass.isEmpty()){
            JOptionPane.showMessageDialog(null, "Campos Vacios", "", JOptionPane.INFORMATION_MESSAGE);
            aceptar = false;
        }
        else{
            if(us.isEmpty()&&pass.isEmpty()!=true){
                JOptionPane.showMessageDialog(null, "Ingresar Usuario", "", JOptionPane.INFORMATION_MESSAGE);
                aceptar = false;
            }
            else{
                if(us.isEmpty()!=true&&pass.isEmpty()){
                    JOptionPane.showMessageDialog(null, "Ingresar Contraseña", "", JOptionPane.INFORMATION_MESSAGE);
                    aceptar = false;
                }
                else{
                    admin=super.obtenerAdministradorLog(us, pass);
                        if(admin!=true){
                            JOptionPane.showMessageDialog(null, "Datos Erroneos...", "Error", JOptionPane.ERROR_MESSAGE);
                            aceptar = false;
                        }
                        else{
                            JOptionPane.showMessageDialog(null, "Bienvenido", "", JOptionPane.INFORMATION_MESSAGE);
                            aceptar = true;
                        }
                   
                }
            }
        }
    }
    
    
    
    public String getUsuario() {
        return usuario;
    }

    public void setUsuario(String usuario) {
        this.usuario = usuario;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public boolean isAceptar() {
        return aceptar;
    }

    public void setAceptar(boolean aceptar) {
        this.aceptar = aceptar;
    }
    
}